// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.commands.serverCommands;

import zombie.characters.IsoPlayer;
import zombie.commands.CommandArgs;
import zombie.commands.CommandBase;
import zombie.commands.CommandHelp;
import zombie.commands.CommandName;
import zombie.commands.RequiredRight;
import zombie.core.logger.LoggerManager;
import zombie.core.math.PZMath;
import zombie.core.raknet.UdpConnection;
import zombie.iso.weather.ClimateManager;
import zombie.network.GameServer;

@CommandName(
    name = "lightning"
)
@CommandArgs(
    optional = "(.+)"
)
@CommandHelp(
    helpText = "UI_ServerOptionDesc_Lightning"
)
@RequiredRight(
    requiredRights = 60
)
public class LightningCommand extends CommandBase {
    public LightningCommand(String username, String userAccessLevel, String command, UdpConnection connection) {
        super(username, userAccessLevel, command, connection);
    }

    @Override
    protected String Command() {
        String string;
        if (this.getCommandArgsCount() == 0) {
            if (this.connection == null) {
                return "Pass a username";
            }

            string = this.getExecutorUsername();
        } else {
            string = this.getCommandArg(Integer.valueOf(0));
        }

        IsoPlayer isoPlayer = GameServer.getPlayerByUserNameForCommand(string);
        if (isoPlayer == null) {
            return "User \"" + string + "\" not found";
        } else {
            int int0 = PZMath.fastfloor(isoPlayer.getX());
            int int1 = PZMath.fastfloor(isoPlayer.getY());
            ClimateManager.getInstance().transmitServerTriggerLightning(int0, int1, false, true, true);
            LoggerManager.getLogger("admin").write(this.getExecutorUsername() + " thunder start");
            return "Lightning triggered";
        }
    }
}
